home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / Mac_F2C_1.3.2.sit / Mac F2C 1.3.2 / Mac F2C v1.3.2 Documentation.rsrc / TEXT_140.txt < prev    next >
Text File  |  1996-10-18  |  16KB  |  351 lines

  1. THINK pre-v7 and Other Compilers
  2.  
  3.  
  4. This chapter provides instructions on how to build the required support libraries if you are using an earlier version of THINK.  It also includes some general guidance for users of other compilers, but because I don窶冲 own any other compilers, I can only provide general guidance. 
  5.  
  6. Use of Mac F2C code with the C++ compiler is strongly not recommended with version 6 of the THINK/Symantec C++ compiler.  There is no C++ compiler prior to version 6.  For these reasons, the C++ libraries and C++ model projects are omitted from the below discussions.
  7.  
  8. If you have THINK version 6, you can upgrade to version 7 and beyond (minus Visual Architect and TCL version 2.0) for free.  Look in your favorite Macintosh archive site for the free updater.
  9.  
  10.  
  11. Building the support libraries with THINK pre-v7    
  12.  
  13. There are five support libraries required to run programs translated by 
  14. Mac F2C.  These libraries are:
  15.  
  16.     (1) ANSI F2C
  17.     (2) unix F2C
  18.     (3) libI77a
  19.     (4) libI77b
  20.     (5) libF77
  21.     
  22. To make ANSI F2C and unix F2C:  Duplicate the ANSI and unix libraries in the Standard Libraries folder (the ones provided by Symantec).  Rename the duplicates ANSI F2C and unix F2C.  Open each one and do the following:
  23.  
  24. 窶「 Remove objects
  25.     
  26. 窶「 In the Options dialog select:
  27.         - 4-byte integers
  28.         - 8-byte doubles
  29.         - 68020 code generation (recommended, not required)
  30.  
  31. 窶「 In the Set Project Type dialog select:
  32.         - Far code
  33.         - Far data
  34.  
  35. 窶「 Bring Up To Date
  36.     
  37. To make libI77a, libI77b, and libF77: In the Mac F2C Libraries folder you will find these three libraries and two folders of source code (libI77 Sources and libF77 Sources).  The process is the same for all three libraries.  I will illustrate it with libI77a:
  38.  
  39. 窶「 Delete libI77a supplied with Mac F2C
  40.     
  41. 窶「 Create a new empty project called libI77a 
  42.  
  43. 窶「 In the Options dialog select:
  44.         - 4-byte integers
  45.         - 8-byte doubles
  46.         - 68020 code generation (recommended, not required)
  47.         - remove the prefix #include <MacHeaders>
  48.         - add the prefix #include TPM_I.h 
  49.           (for libI77a and libI77b only)
  50.         - add the prefix #include TPM_F.h  
  51.           (for libF77 only)
  52.  
  53. 窶「 In the Set Project Type dialog select:
  54.         - Far code
  55.         - Far data
  56.         
  57. 窶「 Add source files from the folder libI77 Sources as required from the corresponding list below.
  58.         
  59. 窶「 Bring the project up to date
  60.     
  61. Repeat this process with libI77b and libF77.  libF77 contains over 
  62. one hundred files.  You may find it easier to include all the source files 
  63. in the folder libF77 Sources initially and then remove the handful that don窶冲 belong in libF77.  Then copy the three built project files into the folder containing the THINK application (you can put them anywhere within the THINK tree).
  64.  
  65.  
  66. Contents of libI77a
  67.  
  68. libI77a
  69. 1 segments
  70. 15 files
  71.  
  72. Segment 2
  73. Name: libI77 Part I
  74. Preload: false, Protected: true, Locked: true
  75. Purgeable: true, SystemHeap: false
  76. 15 files:
  77. access.c              backspace.c                close.c                 dfe.c
  78. dolio.c                due.c                           endfile.c              err.c
  79. fmt.c                  fmtlib.c                      iio.c                     ilnw.c
  80. inquire.c            lread.c                        lwrite.c              DoMultiTask.c
  81.  
  82.  
  83. Contents of libI77b
  84.  
  85. libI77b
  86. 1 segments
  87. 18 files
  88.  
  89. Segment 3
  90. Name: libI77 Part II
  91. Preload: false, Protected: true, Locked: true
  92. Purgeable: true, SystemHeap: false
  93. 18 files:
  94. open.c                 rdfmt.c                      rewind.c              rsfe.c
  95. rsli.c                  rsne.c                        sfe.c                     sue.c
  96. typesize.c           uio.c                          util.c                    Version.c
  97. wref.c                 wrtfmt.c                   wsfe.c                   wsle.c
  98. wsne.c                 xwsne.c
  99.  
  100.  
  101. Contents of libF77
  102.  
  103. libF77
  104. 1 segments
  105. 115 files
  106.  
  107. Segment 2
  108. Name: libF77
  109. Preload: false, Protected: true, Locked: true
  110. Purgeable: true, SystemHeap: false
  111. 115 files:
  112. abort_.c              cabs.c                        c_abs.c                 c_cos.c
  113. c_div.c                c_exp.c                     c_log.c                  c_sin.c
  114. c_sqrt.c              derfc_.c                    derf_.c                  d_abs.c
  115. d_acos.c              d_asin.c                    d_atan.c                d_atn2.c
  116. d_cnjg.c              d_cos.c                     d_cosh.c                d_dim.c
  117. d_exp.c               d_imag.c                   d_int.c                  d_lg10.c
  118. d_log.c                d_mod.c                    d_nint.c                d_prod.c
  119. d_sign.c              d_sin.c                     d_sinh.c                d_sqrt.c
  120. d_tan.c                d_tanh.c                   ef1asc_.c              ef1cmc_.c
  121. erfc_.c                erf_.c                       erf_fctns.c           getarg_.c
  122. getenv_.c            getpid.c                     hl_ge.c                  hl_gt.c
  123. hl_le.c                hl_lt.c                      h_abs.c                  h_dim.c
  124. h_dnnt.c              h_indx.c                  h_len.c                  h_mod.c
  125. h_nint.c              h_sign.c                   iargc_.c                 i_abs.c
  126. i_dim.c               i_dnnt.c                    i_indx.c                 i_len.c
  127. i_mod.c               i_nint.c                    i_sign.c                 l_ge.c
  128. l_gt.c                  l_le.c                        l_lt.c                     pause.c
  129. pow_ci.c             pow_dd.c                  pow_di.c                pow_hh.c
  130. pow_ii.c             pow_ri.c                  pow_zi.c                pow_zz.c
  131. r_abs.c               r_acos.c                   r_asin.c                 r_atan.c
  132. r_atn2.c             r_cnjg.c                   r_cos.c                  r_cosh.c
  133. r_dim.c              r_exp.c                    r_imag.c                r_int.c
  134. r_lg10.c            r_log.c                     r_mod.c                  r_nint.c
  135. r_sign.c             r_sin.c                     r_sinh.c                 r_sqrt.c
  136. r_tan.c               r_tanh.c                   signal_.c                sig_die.c
  137. system_.c           s_cat.c                      s_cmp.c                 s_copy.c
  138. s_paus.c             s_rnge.c                    s_stop.c                 Version.c
  139. z_abs.c               z_cos.c                      z_div.c                   z_exp.c
  140. z_log.c                z_sin.c                     z_sqrt.c
  141.  
  142.  
  143. Converting the Test Project to THINK pre-v7
  144.  
  145. The folder Test Project ニ’ contains a project file called Test.マ\.  To create a version compatible with your version of THINK C, do the following:
  146.  
  147. 窶「 Delete Test.マ\
  148.     
  149. 窶「 Create a new empty project called Test.マ\
  150.  
  151. 窶「 In the Options dialog select:
  152.         - 4-byte integers
  153.         - 8-byte doubles
  154.         - 68020 code generation (recommended, not required)
  155.         - remove the prefix #include <MacHeaders>
  156.  
  157. 窶「 In the Set Project Type dialog select:
  158.         - Far code
  159.         - Far data
  160.         
  161. 窶「 Add sources and libraries as required to match the list that appears below (you will not be able to add test.c until you create it by translating test.f with Mac F2C).  Segment the project as indicated in the list below (in some versions of THINK C you cannot name the segments; this is not a problem, just ignore the segment names).
  162.  
  163.  
  164. Contents of Test.マ\
  165.  
  166. Test.マ\
  167. 6 segments
  168. 7 files
  169.  
  170. Segment 2
  171. Name: Your Code Here
  172. Preload: false, Protected: true, Locked: true
  173. Purgeable: true, SystemHeap: false
  174. 2 files:
  175. F2Cmain.c                 test.c (you cannot add test.c until you create it)
  176.  
  177. Segment 3
  178. Name: libF77
  179. Preload: false, Protected: false, Locked: false
  180. Purgeable: false, SystemHeap: false
  181. 1 files:
  182. Mac F2C Libraries:libF77
  183.  
  184. Segment 4
  185. Name: libI77 Part A
  186. Preload: false, Protected: true, Locked: true
  187. Purgeable: true, SystemHeap: false
  188. 1 files:
  189. Mac F2C Libraries:libI77a
  190.  
  191. Segment 5
  192. Name: libI77 Part B
  193. Preload: false, Protected: true, Locked: true
  194. Purgeable: true, SystemHeap: false
  195. 1 files:
  196. Mac F2C Libraries:libI77b
  197.  
  198. Segment 6
  199. Name: ANSI for F2C
  200. Preload: false, Protected: true, Locked: true
  201. Purgeable: true, SystemHeap: false
  202. 1 files:
  203. Standard Libraries:ANSI F2C
  204.  
  205. Segment 7
  206. Name: UNIX for F2C
  207. Preload: false, Protected: true, Locked: true
  208. Purgeable: true, SystemHeap: false
  209. 1 files:
  210. Standard Libraries:unix F2C
  211.  
  212.  
  213. Using the Project Model with THINK pre-v7
  214.  
  215. The project model is the folder Mac F2C Project which is located in the  folder For '(Project Models)'.  The folder Mac F2C Project contains the following files:
  216.  
  217. 窶「 @1.マ\ -- a THINK C version 7.0 project file.
  218.     
  219. 窶「 main.c -- a driver program required to run programs compiled by Mac F2C.
  220.                     
  221. 窶「 f2c.h -- a header file required by code compiled by Mac F2C.
  222.     
  223. This what you need to compile, link, and run files produced by Mac F2C. In THINK C version 7.0 or later, the THINK project manager automatically makes a copy of the entire model project (i.e., the entire Mac F2C Project folder) and renames the folder and project file when you create a new project using this model.  To use the project model with versions of THINK C prior to 7.0, you will need to:
  224.     
  225. 窶「 replace @1.マ\ which a project compatible with your version of THINK.
  226.     
  227. 窶「 every time you want to create a new project for Mac F2C code, duplicate the project model folder by hand and rename the folder and project file by hand.
  228.         
  229. To create a version of @1.マ\ compatible with your version of THINK C, do the following:
  230.  
  231. 窶「 Delete @1.マ\
  232.     
  233. 窶「 Create a new empty project called @1.マ\
  234.  
  235. 窶「 In the Options dialog select:
  236.         - 4-byte integers
  237.         - 8-byte doubles
  238.         - 68020 code generation (recommended, not required)
  239.         - remove the prefix #include <MacHeaders>
  240.  
  241. 窶「 In the Set Project Type dialog select:
  242.         - Far code
  243.         - Far data
  244.         
  245. 窶「 Add sources and libraries as required to match the list that appears below.   Segment the project as indicated (in some versions of THINK C you cannot name the segments; this is not a problem).
  246.  
  247.  
  248. Contents of @1.マ\
  249.  
  250. @1.マ\
  251. 7 segments
  252. 9 files
  253.  
  254. Segment 2
  255. Name: Your Code Here
  256. Preload: false, Protected: true, Locked: true
  257. Purgeable: true, SystemHeap: false
  258. 1 files:
  259. F2Cmain.c                         <your code goes here or in new segments>
  260.  
  261. Segment 3
  262. Name: libF77
  263. Preload: false, Protected: false, Locked: false
  264. Purgeable: false, SystemHeap: false
  265. 1 files:
  266. Mac F2C Libraries:libF77
  267.  
  268. Segment 4
  269. Name: libI77 Part A
  270. Preload: false, Protected: true, Locked: true
  271. Purgeable: true, SystemHeap: false
  272. 1 files:
  273. Mac F2C Libraries:libI77a
  274.  
  275. Segment 5
  276. Name: libI77 Part B
  277. Preload: false, Protected: true, Locked: true
  278. Purgeable: true, SystemHeap: false
  279. 1 files:
  280. Mac F2C Libraries:libI77b
  281.  
  282. Segment 6
  283. Name: ANSI for F2C
  284. Preload: false, Protected: true, Locked: true
  285. Purgeable: true, SystemHeap: false
  286. 1 files:
  287. Standard Libraries:ANSI F2C
  288.  
  289. Segment 7
  290. Name: UNIX for F2C
  291. Preload: false, Protected: true, Locked: true
  292. Purgeable: true, SystemHeap: false
  293. 1 files:
  294. Standard Libraries:unix F2C
  295.  
  296. Segment 8
  297. Name: Mac Stuff
  298. Preload: false, Protected: true, Locked: true
  299. Purgeable: true, SystemHeap: false
  300. 2 files:
  301. MacTraps                         MacTraps2
  302.  
  303.  
  304. Using Mac F2C with Other Compilers
  305.  
  306. If you use a compiler other than THINK C/C++, Symantec C/C++, or CodeWarrior C/C++ you will have to make libraries on your own.  You will almost certainly have to make some minor modifications to some of the source files in the support libraries.
  307.  
  308. You can use the contents listing that appear above to figure out what to put in each library.  If your compiler/linker allows libraries larger than 32K, you can combine libI77a and libI77b into a single library.  In that case you can also combine all three (libI77a, libI77b, and libF77) into a single library if you so desire.
  309.  
  310. Make sure to compile the libraries so that integers are 4-bytes, doubles are 8-bytes, and you can have more than 32K of static/global data and jump tables larger than 32K.  See the sections on 窶弑sing Code Generated by Mac F2C窶 in the THINK v7 and CodeWarrior chapters for more information on these requirements and when they can be relaxed.
  311.  
  312. You must also #define the following things when compiling these files:
  313.  
  314. For libF77
  315.     <None>
  316.     
  317. For libI77a and libI77b 
  318.     #define NON_UNIX_STDIO      // force the use of ANSI standard I/O
  319.     #define _POSIX_SOURCE        // force the use of mktemp() functions
  320.  
  321. Most of the files in the Mac F2C support libraries compile without trouble on Macintoshes.  Nevertheless, I had to modify a few files, and in doing so I sometimes had to rely on features specific to the THINK and CodeWarrior compilers.  The files in question are:
  322.  
  323. In libI77:
  324.  
  325. 窶「 access.c  This function returns 0 if file called fileName exists, 1 otherwise.  I wrote this from scratch using a Macintosh Toolbox call, so it should work with any Macintosh compiler.
  326.     
  327. In libF77:
  328.  
  329. 窶「 erf_fctns.c  THINK C does not provide error functions in their library.  I wrote my own.  They have decent numeric properties and will compile with any ANSI C compiler.  You may wish to replace this file with (perhaps faster) vendor provided error functions.
  330.     
  331. 窶「 getenv_.c  I had to write my own.  I wrote one that returns a blank environment string.  Modify as appropriate for your compiler.
  332.  
  333. 窶「 getpid.c  I had to write my own.  I exploited a global variable that is defined and maintained by the THINK C unix library.  CodeWarrior doesn窶冲 define these, so in this case I just  defined by own. You will have to modify this file to work with your system.  If all else fails, return 0.
  334.  
  335. Code produced by Mac F2C also relies on the THINK C ANSI and unix libraries.  The THINK C ANSI library is exactly what it says it is.  Your compiler should include such a library.  The THINK C unix library provides a large collection of functions commonly available on unix systems.  Your compiler may or may not include such a library.  If it doesn窶冲, you will get link errors when compiling programs produced by Mac F2C.  You will have to provide the missing functions yourself.  It窶冱 actually not hard to do, especially because in many cases you only need a place holder function (e.g., see getenv_.c or getpid.c).  When a placeholder isn窶冲 enough, you can figure what the function needs to do by checking a unix manual or using the man command on a unix system.
  336.  
  337. In any case make sure your versions of the ANSI and unix libraries are compiled with the proper options (4-byte integers, 8-byte doubles, jump tables larger than 32K, global data larger than 32K, and any C++ compatibility options if you plan to ever produce C++ code as Mac F2C output).
  338.  
  339. Finally, to run a program translated by Mac F2C, you need to link the following things together (this is automatically set up for THINK C users by the model project):
  340.  
  341.     -   your translated code
  342.     -   main.c
  343.     -   libI77a
  344.     -   libI77b
  345.     -   libF77
  346.     -   ANSI libraries
  347.     -   unix libraries
  348.     
  349. The file main.c is a driver that sets up a bunch of things and then calls the translated version of the FORTRAN main program.  I modified main.c to use the THINK C console interface.  In particular, main.c calls the function ccommand() to get command-line arguments from the user.  You will need to modify this accordingly for your compiler.
  350.  
  351. Good luck.  If you have any questions, feel free to email me at igormt@alumni.caltech.edu.  If you make a stable, general purpose port of the libraries and/or F2Cmain.c to another Macintosh compiler, send me a copy and I will include it in future distributions of Mac F2C (with full credit and much gratitude).